<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Search.aspx.vb" Inherits="GTSWeb_Shipment_Manage" title="GTS Frieght Management System"  MaintainScrollPositionOnPostback="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
   <h3>Search Shipments</h3>
    <p>
        <table>
            <tr>
                <td style="width: 162px; text-align: right">
                    <strong>Reference Number&nbsp; </strong>
                </td>
                <td style="width: 208px; text-align: left">
                    <asp:TextBox ID="txtReferenceNumber" runat="server"></asp:TextBox></td>
                <td style="width: 157px; text-align: right;">
                    <strong>Begin Date&nbsp;</strong></td>
                <td style="width: 135px">
                    <asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 162px; text-align: right">
                    <strong>Description </strong>
                </td>
                <td style="width: 208px; text-align: left">
                    <asp:TextBox ID="txtDescription" runat="server"></asp:TextBox></td>
                <td style="width: 157px; text-align: right;">
                    <strong>End Date&nbsp; </strong>
                </td>
                <td style="width: 135px">
                    <asp:TextBox ID="txtBeginDate" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="4" style="height: 22px; text-align: right">
                    <asp:LinkButton ID="lnk" runat="server" BackColor="#E0E0E0" Height="11px" Width="155px">Search Shipments</asp:LinkButton></td>
            </tr>
        </table>
        <asp:Label ID="lblMessage" runat="server"></asp:Label></p>
    <p>
        <asp:GridView ID="dgrSearchShipments" runat="server" CellPadding="4" ForeColor="#333333"
            GridLines="None" PageSize="4" Width="100%" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ReferenceNumber">
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" />
            <EditRowStyle BackColor="#999999" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ReferenceNumber" HeaderText="ReferenceNumber" ReadOnly="True"
                    SortExpression="ReferenceNumber" Visible="False" />
                <asp:BoundField DataField="ShipmentDate" HeaderText="ShipmentDate" SortExpression="ShipmentDate" />
                <asp:BoundField DataField="CarrierID" HeaderText="CarrierID" SortExpression="CarrierID" Visible="False" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="ShipmentNumber" HeaderText="ShipmentNumber" SortExpression="ShipmentNumber" />
                <asp:HyperLinkField DataNavigateUrlFields="ReferenceNumber" DataNavigateUrlFormatString="~/GTSWeb/Reports/routingorder.aspx?ReferenceNumber={0}"
               Text="Routing Order" />
                <asp:HyperLinkField DataNavigateUrlFields="ReferenceNumber" DataNavigateUrlFormatString="~/GTSWeb/Reports/billoflading.aspx?ReferenceNumber={0}"
                Text="Bill of Lading" />
            </Columns>
        </asp:GridView>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4"
            DataKeyNames="ReferenceNumber,ClientID,ClientBranchID,UserName" DataSourceID="ShipmentSource" ForeColor="#333333"
            GridLines="None" Height="50px" Width="100%">
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <EditRowStyle BackColor="#999999" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <Fields>
                <asp:BoundField DataField="ReferenceNumber" HeaderText="ReferenceNumber" ReadOnly="True"
                    SortExpression="ReferenceNumber" />
                <asp:BoundField DataField="ShipmentDate" HeaderText="ShipmentDate" SortExpression="ShipmentDate" />
                <asp:TemplateField HeaderText="ClientID" SortExpression="ClientID" Visible="False">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ClientID") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ClientID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ClientID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ClientBranchID" HeaderText="ClientBranchID" SortExpression="ClientBranchID" Visible="False" />
                <asp:TemplateField HeaderText="CarrierID" SortExpression="CarrierID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" BackColor="White" DataSourceID="carrierSource"
                            DataTextField="CarrierName" DataValueField="CarrierID" ForeColor="Black" SelectedValue='<%# Bind("CarrierID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="carrierSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="getCarrierByClientBranchId" TypeName="GTSSystem.BLL.Carrier">
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="BranchId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("CarrierID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" BackColor="White" DataSourceID="carrierSource"
                            DataTextField="CarrierName" DataValueField="CarrierID" Enabled="False" ForeColor="Black" SelectedValue='<%# Bind("CarrierID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="carrierSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="getCarrierByClientBranchId" TypeName="GTSSystem.BLL.Carrier">
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="BranchId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Weight" HeaderText="Weight" SortExpression="Weight" />
                <asp:TemplateField HeaderText="ServiceTypeID" SortExpression="ServiceTypeID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" BackColor="White" DataSourceID="ServiceTypeSource"
                            DataTextField="ServiceTypeName" DataValueField="ServiceTypeID" ForeColor="Black" SelectedValue='<%# Bind("ServiceTypeID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="ServiceTypeSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetServiceType" TypeName="GTSSystem.BLL.ServiceType"></asp:ObjectDataSource>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ServiceTypeID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" BackColor="White" DataSourceID="ServiceTypeSource"
                            DataTextField="ServiceTypeName" DataValueField="ServiceTypeID" Enabled="False"
                            ForeColor="Black" SelectedValue='<%# Bind("ServiceTypeID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="ServiceTypeSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetServiceType" TypeName="GTSSystem.BLL.ServiceType"></asp:ObjectDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="GST" HeaderText="GST" SortExpression="GST" />
                <asp:BoundField DataField="PST" HeaderText="PST" SortExpression="PST" />
                <asp:BoundField DataField="HST" HeaderText="HST" SortExpression="HST" />
                <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" />
                <asp:BoundField DataField="SurchargeAmount" HeaderText="SurchargeAmount" SortExpression="SurchargeAmount" />
                <asp:BoundField DataField="Surcharge" HeaderText="Surcharge" SortExpression="Surcharge" />
                <asp:BoundField DataField="NrOfPieces" HeaderText="NrOfPieces" SortExpression="NrOfPieces" />
                <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" ReadOnly="True" Visible="False" />
                <asp:TemplateField HeaderText="StatusID" SortExpression="StatusID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="StatusSource" DataTextField="StatusName"
                            DataValueField="StatusID" SelectedValue='<%# Bind("StatusID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="StatusSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="getStatus" TypeName="GTSSystem.BLL.Status"></asp:ObjectDataSource>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("StatusID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" BackColor="White" DataSourceID="StatusSource"
                            DataTextField="StatusName" DataValueField="StatusID" Enabled="False" ForeColor="Black"
                            SelectedValue='<%# Bind("StatusID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="StatusSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="getStatus" TypeName="GTSSystem.BLL.Status"></asp:ObjectDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ShipmentNumber" HeaderText="ShipmentNumber" SortExpression="ShipmentNumber" />
                <asp:BoundField DataField="OriginAddress" HeaderText="OriginAddress" SortExpression="OriginAddress" />
                <asp:TemplateField HeaderText="Origin" SortExpression="OriginID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="OriginSource" DataTextField="City"
                            DataValueField="RateLocationID" SelectedValue='<%# Bind("OriginID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="OriginSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetRateLocation" TypeName="GTSSystem.BLL.RateLocation">
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="BranchId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("OriginID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList4" runat="server" BackColor="White" DataSourceID="OriginSource"
                            DataTextField="City" DataValueField="RateLocationID" Enabled="False" ForeColor="Black"
                            SelectedValue='<%# Bind("OriginID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="OriginSource" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetRateLocation" TypeName="GTSSystem.BLL.RateLocation">
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="BranchId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="OriginPostalCode" HeaderText="OriginPostalCode" SortExpression="OriginPostalCode" />
                <asp:BoundField DataField="DestinationAddress" HeaderText="DestinationAddress" SortExpression="DestinationAddress" />
                <asp:TemplateField HeaderText="Destination" SortExpression="DestinationID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="destinationSource"
                            DataTextField="City" DataValueField="RateLocationID" SelectedValue='<%# Bind("DestinationID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="destinationSource" runat="server" InsertMethod="AddRateLocation"
                            OldValuesParameterFormatString="original_{0}" SelectMethod="GetRateLocation"
                            TypeName="GTSSystem.BLL.RateLocation" UpdateMethod="UpdateRateLocation">
                            <UpdateParameters>
                                <asp:Parameter Name="RateLocationID" Type="Int32" />
                                <asp:Parameter Name="City" Type="String" />
                                <asp:Parameter Name="Province" Type="String" />
                                <asp:Parameter Name="Country" Type="String" />
                            </UpdateParameters>
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="Branchid" Type="Int32" />
                            </SelectParameters>
                            <InsertParameters>
                                <asp:Parameter Name="BranchID" Type="Int32" />
                                <asp:Parameter Name="City" Type="String" />
                                <asp:Parameter Name="Province" Type="String" />
                                <asp:Parameter Name="Country" Type="String" />
                            </InsertParameters>
                        </asp:ObjectDataSource>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("DestinationID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList5" runat="server" BackColor="White" DataSourceID="destinationSource"
                            DataTextField="City" DataValueField="RateLocationID" Enabled="False" ForeColor="Black"
                            SelectedValue='<%# Bind("DestinationID") %>'>
                        </asp:DropDownList><asp:ObjectDataSource ID="destinationSource" runat="server" InsertMethod="AddRateLocation"
                            OldValuesParameterFormatString="original_{0}" SelectMethod="GetRateLocation"
                            TypeName="GTSSystem.BLL.RateLocation" UpdateMethod="UpdateRateLocation">
                            <UpdateParameters>
                                <asp:Parameter Name="RateLocationID" Type="Int32" />
                                <asp:Parameter Name="City" Type="String" />
                                <asp:Parameter Name="Province" Type="String" />
                                <asp:Parameter Name="Country" Type="String" />
                            </UpdateParameters>
                            <SelectParameters>
                                <asp:ProfileParameter Name="BranchID" PropertyName="Branchid" Type="Int32" />
                            </SelectParameters>
                            <InsertParameters>
                                <asp:Parameter Name="BranchID" Type="Int32" />
                                <asp:Parameter Name="City" Type="String" />
                                <asp:Parameter Name="Province" Type="String" />
                                <asp:Parameter Name="Country" Type="String" />
                            </InsertParameters>
                        </asp:ObjectDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="DestinationPostalCode" HeaderText="DestinationPostalCode"
                    SortExpression="DestinationPostalCode" />
                <asp:CommandField ShowEditButton="True" />
            </Fields>
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" Width="200px" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderTemplate>
                Shipment Details
            </HeaderTemplate>
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ShipmentSource" runat="server" OldValuesParameterFormatString="{0}"
            SelectMethod="getShipmentByReferencenumber" TypeName="GTSSystem.BLL.Shipment"
            UpdateMethod="UpdateShipment" InsertMethod="CreateShipment">
            <UpdateParameters>
                <asp:Parameter Name="ReferenceNumber" Type="Int32" />
                <asp:Parameter Name="Shipmentdate" Type="DateTime" />
                <asp:Parameter Name="ClientId" Type="Int32" />
                <asp:Parameter Name="ClientBranchid" Type="Int32" />
                <asp:Parameter Name="CarrierId" Type="Int32" />
                <asp:Parameter Name="Weight" Type="Double" />
                <asp:Parameter Name="OriginID" Type="Int32" />
                <asp:Parameter Name="OriginAddress" Type="String" />
                <asp:Parameter Name="OriginPostalCode" Type="String" />
                <asp:Parameter Name="DestinationID" Type="Int32" />
                <asp:Parameter Name="DestinationAddress" Type="String" />
                <asp:Parameter Name="DestinationPostalCode" Type="String" />
                <asp:Parameter Name="ServiceTypeId" Type="Int32" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="GST" Type="Double" />
                <asp:Parameter Name="PST" Type="Double" />
                <asp:Parameter Name="HST" Type="Double" />
                <asp:Parameter Name="Surcharge" Type="Double" />
                <asp:Parameter Name="NrOfPieces" Type="Int32" />
                <asp:Parameter Name="UserName" Type="String" />
                <asp:Parameter Name="StatusId" Type="Int32" />
                <asp:Parameter Name="ShipmentNumber" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="dgrSearchShipments" Name="ReferenceNumber" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            
        </asp:ObjectDataSource>
        &nbsp; &nbsp;
    </p>
   
</asp:Content>